package Java测试.编码8;

//8 求1+2!+3!+...+20!的和？//结果为268040729
public class Testcopy {
    public static void main(String[] args) {
        System.out.println("1!+2!+3!+……+20!="+show(20));
    }
    public static int show(int n){
        int i,j,k,sum=0;
        for (i = 1;  i<=n ;i ++) {
            k=1;
            for (j = 1; j <=i;j ++)
                k=k*j;
                sum+=k;
            }
            return sum;
    }
}
